package com.template.utils;

import java.util.regex.Pattern;

/**
 * 信息合法性校验工具包
 */
public class ValidUtils {

    /**
     * 验证手机号合法性
     */
    public static boolean phone(String phone) {
        if ((phone != null) && (!phone.isEmpty())) {
            return Pattern.matches("^1[3-9]\\d{9}$", phone);
        }
        return false;
    }

    /**
     * 验证邮箱合法性
     */
    public static boolean email(String email) {
        if ((email != null) && (!email.isEmpty())) {
            return Pattern.matches("^(\\w+([-.][A-Za-z0-9]+)*){3,18}@\\w+([-.][A-Za-z0-9]+)*\\.\\w+([-.][A-Za-z0-9]+)*$", email);
        }
        return false;
    }

}